import shutil, os, sys
from pathlib import Path
import datetime
import updateModelParamsUtils


if __name__ == "__main__":  
    currentTime = datetime.datetime.now().strftime('%Y-%m-%d  %H:%M:%S')
    currentDate = datetime.datetime.now().strftime('%Y-%m-%d')

    rootPath = 'F:\\workespace\\z_projects\\woge-models\\0_model_v2/'  #F:\workespace\z_projects\woge-models\0_model_v2
    idx_0 = '27RS_800463'

    commitInfo = "新版算法"
    dstModelIdx = ['KSB_24818',
                   '27RS_800463', 
                   '31.5_HX'
                   ]
    # dstModelIdx = ['12.3_23824', '15.6_24803', 
    #                '27_23805', '27.2', '27_23822','27_24833','27_31.5','27_800463', 
    #                '31.5_23809',"31.5_800463", "31.5_24834", 
    #                '32_24818', 
    #                '34_22816', '49', '65_23821', '85_24804']
    

    isPublish = False
    commitInfo += (", 同步model-"+idx_0)

    #非更新step ***************重要
    stepIdxListNot = [74, 120,71,80,  
                      337,154,136,145
                      ,338,355,348,352,6,146  #焊片测量step
                      ,200,202      #焊盘开窗尺寸
                      ]
    

    inputStr = input("\n当前源model："+idx_0+"\n是否确认更新(y/n): ")
    print(inputStr)
    if inputStr != 'y':
        print("指令错误: " + inputStr)
        exit(0)
    
    modelPath = rootPath+idx_0+'/'
    modelName = "model-"+idx_0
    srcModelPath = modelPath+modelName
    if( not os.path.exists(srcModelPath)):
            print("path not exist: ", srcModelPath)
            exit(0)
    else:
         print(">>> src model: ", srcModelPath)
         print(">>>")

    srcModelPath += "/"

    dstModelPathList = []
    for idx in dstModelIdx:
        modelPath = rootPath+(idx)+'/'
        modelName = "model-"+(idx)+"/"
        dstModelPath = modelPath+modelName
        dstModelPathList.append(dstModelPath)

    publish = rootPath if isPublish else None
    updateModelParamsUtils.modelUpdateDemo(commitInfo, srcModelPath,dstModelPathList,stepIdxListNot,publish)
    print("update complate ...")
    

    exit(0)

    
